<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登陆界面</title>

    <script src="js/jquery-1.11.0.min.js"></script>
</head>
<body>
<form>
    <table align="center" width="30%" border="1">
        <tr>
            <td align="center"><h1>用户登录</h1></td>
        </tr>
        <tr>
            <td align="left">
                手机号:<input type="text" name="phone_num" id="phone_num" > <span id="phone_msg" style="color: crimson;"></span> <br>
                密码: <input type="password" name="password" id="password"> <span id="pwd_msg" style="color: crimson;"></span> <br>
            </td>
        </tr>

        <tr>
            <td align="center">
                <input type="button" value="登录" id="login">
            </td>
        </tr>

    </table>
</form>

</body>

<script>

    //校验手机号与密码

    //登录动作
    $("#login").click(function () {
        //获取手机号和密码
        let phoneNum = $("#phone_num").val();
        let password = $("#password").val();
        //发送异步请求,进行登录验证
        $.post("login",{"phoneNum":phoneNum,"password":password},function (data) {
            if (data == "true"){
                //登录成功

                $.get("type",{"phoneNum":phoneNum},function(date){
                        if (date == "1"){
                            //跳转到账户列表
                            location.href = "account_index.jsp"
                        }else {
                            //跳转到开户界面
                            location.href = "openaccount.html"
                        }
                })

            }else {
                //登陆失败
                alert("手机号或密码错误")
            }
        },"text");

    });
</script>
</html>